package com.cxyzy.glidedemo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.Glide
import com.bumptech.glide.load.MultiTransformation
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import kotlinx.android.synthetic.main.activity_logo.*

class RoundCornerAndCenterCropActivity : AppCompatActivity() {

    private val url = "https://c-ssl.duitang.com/uploads/item/201706/05/20170605121955_mkz2y.thumb.700_0.jpeg"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_logo)
        centerCropImg()
        roundCornerImg()
        centerCropAndRoundCornerImg()
    }

    private fun centerCropImg() {
        Glide.with(this)
                .load(url)
                .centerCrop()
                .into(roundCornerIv)
    }

    private fun roundCornerImg() {
        Glide.with(this)
                .load(url)
                .transform(RoundedCorners(20))
                .into(centerCropIv)
    }

    private fun centerCropAndRoundCornerImg() {
        Glide.with(this)
                .load(url)
                .transform(MultiTransformation(CenterCrop(), RoundedCorners(20)))
                .into(roundCornerAndCenterCropIv)
    }
}
